var spawn = require('child_process').spawn;

function run() {
    free = spawn('push.bat');
    console.log("pushed");
//
// 捕获标准输出并将其打印到控制台
    free.stdout.on('data', function (data) {
        console.log('standard output:\n' + data);
    });

// 捕获标准错误输出并将其打印到控制台
    free.stderr.on('data', function (data) {
        console.log('standard error output:\n' + data);
    });

}


const fs = require("fs");
let lastFileName = null;
fs.watch(__dirname, function (event, filename) {
    if (!filename.includes("git")&&filename.indexOf("___jb_tmp___") === -1 && filename.indexOf("___jb_old___") === -1 && lastFileName !== filename) {
        console.log("changed");
        run();
        lastFileName = filename;
        setTimeout(_=>{
            lastFileName = null;
        },100)
    }
});

